home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / pxewin.zip / PXDISPLY.HPP < prev    next >
C/C++ Source or Header  |  1992-01-08  |  4KB  |  149 lines

  1. // PXDISPLY.HPP //
  2.  
  3. // Contents ----------------------------------------------------------------
  4. //
  5. //      PXDIS class for opening a table and initializing the record buffer
  6. //    and all the fields.
  7. //
  8. // Description -------------------------------------------------------------
  9. //
  10. //    This header contains classes for displaying a Paradox database in
  11. //    Windows.
  12. //
  13. // End ---------------------------------------------------------------------
  14.  
  15. // External Reference Name for this Header ---------------------------------
  16.  
  17. #ifndef PXDISPLY_HPP
  18.     #define PXDISPLY_HPP
  19.  
  20. // End ---------------------------------------------------------------------
  21.  
  22. // Interface Dependencies --------------------------------------------------
  23.  
  24. #ifndef PXSTRUCT_HPP
  25.     #include "pxstruct.hpp"
  26. #endif
  27.  
  28. // End ---------------------------------------------------------------------
  29.  
  30. // enum DISPLAY //
  31.  
  32. enum DISPLAY
  33. {
  34.     RECORD,                    /* One record is displayed
  35.                            per window. */
  36.     PAGE                    /* A page of records are
  37.                            displayed in a window. */
  38. };
  39.  
  40. // class PXDIS //
  41.  
  42. class PXDIS:public PXRec
  43. {
  44. public:
  45.     PXField **my_field;            /* Fields list */
  46.     PXDIS::PXDIS()
  47.     {
  48.         // NULL out all your field pointer.
  49.  
  50.         my_field = NULL;
  51.     }
  52.     int SetUp(int index,int mode,        /* Set up database */
  53.         int op,int display);
  54.     ~PXDIS(void);                /* Destroy display */
  55.     char *Get(int i)            /* Get the data from the
  56.                            right field */
  57.     {
  58.         return my_field[i]->Get();
  59.     }
  60. };
  61.  
  62. // Description -------------------------------------------------------------
  63. //
  64. //    This is the display class that allows displaying a database in a
  65. //    window.
  66. //
  67. // End ---------------------------------------------------------------------
  68.  
  69. int PXDIS::SetUp(int index,int mode,int op,int display)
  70. {
  71.     int i;                              /* Field index */
  72.     FIELDHANDLE fld;
  73.  
  74.     // Null out your pointers in case a delete is called before
  75.     // new
  76.  
  77.     my_field = NULL;
  78.  
  79.     // Open the table
  80.  
  81.     if(PXTbl::Open(index,mode,op) != PXSUCCESS)
  82.         return pxerr;
  83.  
  84.     // Open record buffer and get the number of records in table
  85.  
  86.     if(PXRec::Open() != PXSUCCESS)
  87.         return pxerr;
  88.  
  89.     // Get the number of fields in the table
  90.  
  91.     NumFlds();
  92.  
  93.     // Make an array of field pointers
  94.  
  95.     my_field = new PXField* [num_fields];
  96.  
  97.     // Get the fields initialized
  98.  
  99.     for(i = 0;i < num_fields;i++)
  100.     {
  101.         fld = i + 1;
  102.         my_field[i] = new PXField(&tblHandle,&recHandle,fld);
  103.     }
  104.     return PXSUCCESS;
  105. }
  106.  
  107. // Summary -----------------------------------------------------------------
  108. //
  109. //    This member initializes the table for display in a window
  110. //
  111. // Parameters --------------------------------------------------------------
  112. //
  113. //    name.  This is the name of the database.
  114. //
  115. //    index.  This the index you wish to use.
  116. //
  117. //    mode.  This is the save mode you wish to open the table with.
  118. //
  119. //    op.  This is the operation you wish to perform on the table.  You
  120. //    can also use the create operation.
  121. //
  122. //    display.  This is the display option you wish to perform.  You can
  123. //    dislay a single record at a time or a page of records.
  124. //
  125. // Function Description ----------------------------------------------------
  126. //
  127. //    1.  Make table object.
  128. //
  129. //    2.  Make record object.
  130. //
  131. //    3.  Get the number of fields in the table.
  132. //
  133. //    4.  Make all your field objects.
  134. //
  135. // End ---------------------------------------------------------------------
  136.  
  137. // destructor PXDIS //
  138.  
  139. PXDIS::~PXDIS(void)
  140. {
  141.     int i;                /* field index */
  142.  
  143.     for(i = 0;i < num_fields;i++)
  144.         delete my_field[i];
  145.     delete my_field;
  146. }
  147.  
  148. #endif
  149.